
#pragma once
#include "SettingDlg.h"
#include "SearchDlg.h"
#include "resource.h"


class BottomDlg : public CAxDialogImpl<BottomDlg>,public CUpdateUI<BottomDlg>,public CMessageFilter,public CIdleHandler
{
public:
	enum { IDD = IDD_DIALOG_BOTTOM };

	virtual BOOL PreTranslateMessage(MSG *pMSG)
	{
		if(m_hWnd)
			return CWindow::IsDialogMessage(pMSG);
		return false;
	}
	CSettingDlg			m_settingDlg;
	CSearchDlg			m_searchDlg;
	virtual BOOL OnIdle()
	{
		return false;
	}
	BEGIN_UPDATE_UI_MAP(BottomDlg)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(BottomDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		COMMAND_ID_HANDLER(IDC_BUTTON_SETTING, OnSetting)
		COMMAND_ID_HANDLER(IDC_BUTTON_SEARCH, OnSearch)
		CHAIN_MSG_MAP(CUpdateUI<BottomDlg>)
	END_MSG_MAP()
	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{

		CMessageLoop* pLoop = _Module.GetMessageLoop();
		ATLASSERT(pLoop != NULL);
		pLoop->AddMessageFilter(this);
		pLoop->AddIdleHandler(this);
		UIAddChildWindowContainer(m_hWnd);

		return true;
	}
	LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
	{
		RECT	rect;
		GetClientRect(&rect);
		bHandled = false;
		return 0;
	}

	LRESULT OnSetting(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		if(m_settingDlg.m_hWnd==NULL)
		{
			m_settingDlg.Create(NULL);
			m_settingDlg.ShowWindow(SW_SHOW);
		}
		return 0;
	}
	LRESULT OnSearch(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		if(m_searchDlg.m_hWnd==NULL)
		{
			m_searchDlg.Create(NULL);
			m_searchDlg.ShowWindow(SW_SHOW);
		}
		return 0;
	}
	
};